<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:dg="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:local="clr-namespace:ESRI.ArcGIS.Client.Toolkit">   
    <Style x:Key="MenuButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Background" Value="#FF1F3B53"/>
        <Setter Property="Foreground" Value="#FF000000"/>
        <Setter Property="Padding" Value="3"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFA3AEB9" Offset="0"/>
                    <GradientStop Color="#FF8399A9" Offset="0.375"/>
                    <GradientStop Color="#FF718597" Offset="0.375"/>
                    <GradientStop Color="#FF617584" Offset="1"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Fill).(Color)" Duration="00:00:00" To="#FFB7DBE6"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value=".55"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="BackgroundGradient" Margin="1" Fill="Transparent"/>
                        <ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        <Rectangle x:Name="DisabledVisualElement" Fill="#FFFFFFFF" RadiusX="3" RadiusY="3" IsHitTestVisible="false" Opacity="0"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="local:FeatureDataGrid">
        <Setter Property="RowBackground" Value="#AAEAEFF4"/>
        <Setter Property="AlternatingRowBackground" Value="#00FFFFFF"/>
        <Setter Property="Background" Value="#FFFFFFFF"/>
		<Setter Property="HeadersVisibility" Value="Column"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="SelectionMode" Value="Extended"/>
        <Setter Property="CanUserReorderColumns" Value="True"/>
        <Setter Property="CanUserResizeColumns" Value="True"/>
        <Setter Property="CanUserSortColumns" Value="True"/>
        <Setter Property="AutoGenerateColumns" Value="True"/>
		<Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFA3AEB9" Offset="0"/>
                    <GradientStop Color="#FF8399A9" Offset="0.375"/>
                    <GradientStop Color="#FF718597" Offset="0.375"/>
                    <GradientStop Color="#FF617584" Offset="1"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="BorderThickness" Value="1"/>                
        <Setter Property="VirtualizingStackPanel.VirtualizationMode" Value="Recycling" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>        
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>        
        <Setter Property="RowHeaderWidth" Value="0" />
        <Setter Property="RowStyle">
            <Setter.Value>
                <Style TargetType="dg:DataGridRow">
                    <Style.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
                            <Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                        </Trigger>                       
                    </Style.Triggers>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:FeatureDataGrid">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                            <ScrollViewer x:Name="DG_ScrollViewer" Focusable="False">
                                <ScrollViewer.Template>
                                    <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto"/>
                                                <ColumnDefinition Width="*"/>
                                                <ColumnDefinition Width="Auto"/>
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="*"/>
                                                <RowDefinition Height="Auto"/>
                                            </Grid.RowDefinitions>
                                            <Button Visibility="Collapsed" Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type local:FeatureDataGrid}}}" Focusable="False">
                                                <Button.Template>
                                                    <ControlTemplate TargetType="{x:Type Button}">
                                                        <Grid>
                                                            <Rectangle x:Name="Border" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" SnapsToDevicePixels="True"/>
                                                            <Polygon x:Name="Arrow" Fill="Black" Stretch="Uniform" HorizontalAlignment="Right" Margin="8,8,3,3" VerticalAlignment="Bottom" Opacity="0.15" Points="0,10 10,10 10,0"/>
                                                        </Grid>
                                                        <ControlTemplate.Triggers>
                                                            <Trigger Property="IsMouseOver" Value="True">
                                                                <Setter Property="Stroke" TargetName="Border" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>
                                                            </Trigger>
                                                            <Trigger Property="IsPressed" Value="True">
                                                                <Setter Property="Fill" TargetName="Border" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>
                                                            </Trigger>
                                                            <Trigger Property="IsEnabled" Value="False">
                                                                <Setter Property="Visibility" TargetName="Arrow" Value="Collapsed"/>
                                                            </Trigger>
                                                        </ControlTemplate.Triggers>
                                                    </ControlTemplate>
                                                </Button.Template>                                               
                                                <Button.Command>
                                                    <RoutedCommand/>
                                                </Button.Command>
                                            </Button>
                                            <dg:DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Grid.Column="1">
                                                <dg:DataGridColumnHeadersPresenter.Visibility>
                                                    <Binding Path="HeadersVisibility" RelativeSource="{RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type local:FeatureDataGrid}}">
                                                        <Binding.ConverterParameter>
                                                            <dg:DataGridHeadersVisibility>Column</dg:DataGridHeadersVisibility>
                                                        </Binding.ConverterParameter>
                                                    </Binding>
                                                </dg:DataGridColumnHeadersPresenter.Visibility>
                                            </dg:DataGridColumnHeadersPresenter>
                                            <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Grid.ColumnSpan="2" Grid.Row="1" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False"/>
                                            <ScrollBar x:Name="PART_VerticalScrollBar" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Grid.Column="2" Grid.Row="1" Maximum="{TemplateBinding ScrollableHeight}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" Orientation="Vertical" ViewportSize="{TemplateBinding ViewportHeight}"/>
                                            <Grid Grid.Column="1" Grid.Row="2">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type local:FeatureDataGrid}}}"/>
                                                    <ColumnDefinition Width="*"/>
                                                </Grid.ColumnDefinitions>
                                                <ScrollBar x:Name="PART_HorizontalScrollBar" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Grid.Column="1" Maximum="{TemplateBinding ScrollableWidth}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}"/>
                                            </Grid>
                                        </Grid>
                                    </ControlTemplate>
                                </ScrollViewer.Template>
                                <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </ScrollViewer>
                        </Border>
                        <!--ESRI Status Bar-->
                        <Grid Grid.Row="1"  Background="{TemplateBinding Background}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <!--Record Navigator-->
                            <StackPanel Grid.Column="0" Orientation="Horizontal">
                                <TextBlock Text="Record:" VerticalAlignment="Center" Margin="1,0,3,0"/>
                                <Button x:Name="MoveFirstButton" Content="&lt;&lt;" Cursor="Hand" ToolTipService.ToolTip="Move First"/>
                                <Button x:Name="MovePreviousButton" Content="&lt;" Cursor="Hand" ToolTipService.ToolTip="Move Previous"/>
                                <Border VerticalAlignment="Center" BorderThickness="0.5" BorderBrush="Gray" >
                                    <TextBox x:Name="CurrentRecordNumberTextBox" Text="" TextAlignment="Right" Width="40"/>
                                </Border>
                                <Button x:Name="MoveNextButton" Content="&gt;" Cursor="Hand" ToolTipService.ToolTip="Move Next"/>
                                <Button x:Name="MoveLastButton" Content="&gt;&gt;" Cursor="Hand" ToolTipService.ToolTip="Move Last"/>
                            </StackPanel>
                            <!--Records selected out of total records-->
                            <TextBlock Grid.Column="1" x:Name="NumberOfRecordsTextBlock" Text="Records ({0} out of {1} Selected)" VerticalAlignment="Center" Margin="3,0,0,0"/>
                            <!--Options-->
                            <Grid Grid.Column="2" Margin="5,0,0,0">
                                <Button x:Name="OptionsButton" Content=" Options... " />
                                <Popup x:Name="PopupMenu" IsOpen="False" AllowsTransparency="True">
                                    <Border BorderThickness="1" CornerRadius="1.5" 
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            Background="{TemplateBinding Background}">
                                        <StackPanel>
                                            <Button x:Name="ClearSelectionMenuButton" Margin="5,5,5,0" Style="{StaticResource MenuButtonStyle}">
                                                <Button.Content>
                                                    <TextBlock Text="Clear Selection" VerticalAlignment="Center" Margin="5"/>
                                                </Button.Content>
                                            </Button>
                                            <Button x:Name="SwitchSelectionMenuButton" Margin="5,0" Style="{StaticResource MenuButtonStyle}">
                                                <Button.Content>
                                                    <TextBlock Text="Switch Selection" VerticalAlignment="Center" Margin="5"/>
                                                </Button.Content>
                                            </Button>
                                            <Button x:Name="SelectAllMenuButton" Margin="5,0" Style="{StaticResource MenuButtonStyle}">
                                                <Button.Content>
                                                    <TextBlock Text="Select All" VerticalAlignment="Center" Margin="5"/>
                                                </Button.Content>
                                            </Button>
                                            <Button x:Name="ZoomToSelectionMenuButton" Margin="5,0" Style="{StaticResource MenuButtonStyle}">
                                                <Button.Content>
                                                    <TextBlock Text="Zoom To Selection" VerticalAlignment="Center" Margin="5"/>
                                                </Button.Content>
                                            </Button>
                                            <Button x:Name="DeleteSelectedRowsMenuButton" Margin="5,0" Style="{StaticResource MenuButtonStyle}">
                                                <Button.Content>
                                                    <TextBlock Text="Remove Selected Row(s)" VerticalAlignment="Center" Margin="5"/>
                                                </Button.Content>
                                            </Button>
                                            <Line X1="10" Y1="2" X2="157" Y2="2" Stroke="Black" StrokeThickness="0.2"/>
                                            <CheckBox x:Name="AutoChangeMapExtentCheckBox" Content="Auto Zoom to Selected" Margin="10,5"/>
                                        </StackPanel>
                                    </Border>
                                </Popup>
                            </Grid>
                            <!--Commit Button-->
                            <Button Grid.Column="3" x:Name="SubmitChangesMenuButton" Margin="5,0" Style="{StaticResource MenuButtonStyle}" IsEnabled="False">
                                <Button.Content>
                                    <TextBlock Text="Commit" VerticalAlignment="Center" Margin="5"/>
                                </Button.Content>
                            </Button>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsGrouping" Value="True">
                <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>
